home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / bas_int1.zip / _DRIVES.BAS next >
BASIC Source File  |  1991-06-09  |  3KB  |  78 lines

  1. '====================================================================
  2. ' Quick Basic Forum
  3. '   Date : 02-Jun-91
  4. '   From : Larry Stone
  5. '     To : Steve Halko
  6. 'Subject : Code to get disk drives
  7. '===================================================================
  8.  
  9. '**** DRIVLIST.BAS - Drive Listing functions by Larry Stone, 1991
  10. '**** Based on a routine published in MicroHelp's BUG Newsletter, 1/1/90
  11.  
  12. DECLARE FUNCTION FloppyDriveList$ ()
  13. DECLARE FUNCTION HardDriveList$ (Floppies$)
  14. '$INCLUDE: 'qb.bi'
  15.  
  16. CLS
  17.  
  18. HardDrives$ = HardDriveList$(Floppies$)
  19. HardDrives% = LEN(HardDrives$)
  20. Floppies% = LEN(Floppies$)
  21. NumDrives% = HardDrives% + Floppies%
  22.  
  23. PRINT "This system has a total of"; NumDrives%; "drives."
  24. PRINT STRING$(80, 205);
  25.  
  26. PRINT "This system has"; Floppies%; "floppy drive(s) ==> ";
  27. FOR N = 1 TO Floppies%
  28.     PRINT MID$(Floppies$, N, 1); ": ";
  29. NEXT
  30. PRINT : PRINT STRING$(80, 205);
  31.  
  32. PRINT "This system has"; HardDrives%; "hard drive(s) ==> ";
  33. FOR N = 1 TO HardDrives%
  34.     PRINT MID$(HardDrives$, N, 1); ": ";
  35. NEXT
  36. PRINT
  37. END
  38.  
  39. FUNCTION FloppyDriveList$
  40.     DEF SEG = 0
  41.     Floppies% = PEEK(&H410) \ 64 + 1   'How many floppy drives installed?
  42.     DEF SEG                            'Back to DGROUP
  43.  
  44.     FOR N% = 1 TO Floppies%            'Place these letters into Floppies$
  45.         scratch$ = scratch$ + CHR$(64 + N%)
  46.     NEXT
  47.  
  48.     FloppyDriveList$ = scratch$        'Set the function.
  49.     scratch$ = ""                      'Grabage collection.
  50. END FUNCTION
  51.  
  52. FUNCTION HardDriveList$ (FloppyList$)
  53.     DIM Reg AS RegType
  54.  
  55.     FloppyList$ = FloppyDriveList$     'Get the floppy drive list.
  56.     Floppies% = LEN(FloppyList$)       'How many drives have we gotten?
  57.  
  58.                                        'If only 1 floppy, first drive is C:
  59.     HardDrive1% = Floppies% + 1 + ABS(Floppies% = 1)
  60.  
  61.     'DOS function AH = 44h & AL = 09h is "Device Driver Control (IOCTL)" and
  62.     'tests whether a drive is local or remote.  If the carry flag is set then
  63.     'AX will return 0Fh when drive letter is invalid.  This routine simply
  64.     'checks to see if the carry flag is set and ends if it is.
  65.  
  66.     FOR BL% = HardDrive1% TO 26         'Roll through possible hard drives.
  67.         Reg.AX = &H4409                 'DOS function "Device Driver Control"
  68.         Reg.BX = BL%                    'Drive letter in BL register.
  69.         INTERRUPT &H21, Reg, Reg        'Call Mr DOS (INT 21h).
  70.         IF (Reg.Flags AND 1) THEN EXIT FOR        'Check carry flag.
  71.         scratch$ = scratch$ + CHR$(64 + Reg.BX)   'Add the letter
  72.     NEXT
  73.  
  74.     HardDriveList$ = scratch$           'Set the function.
  75.     scratch$ = ""                       'Garbage collection.
  76. END FUNCTION
  77.  
  78.